
$(document).ready(function() {
	// image 클릭시.
	/*try{
		$('#userDetailView').prepend('<div id="tempImgArea" align="center" style="display:none;"></div>');
		$("#profile_img_seq").bind("load", function(){	
			$(this)
			.attr({alt: "클릭하시면 원본 사이즈로 보실 수 있습니다."})
			.css({cursor: "pointer"})
			.on("click", function(){
				$("#tempImgArea").html("");
				
				var img = new Image();
				img.src = $('#profile_img_seq').attr('src');
				var imgcopy = $("#profile_img_seq").clone(); 
				$("#tempImgArea").append(imgcopy);
				
				img.onload = function() {
					width = this.width;
					height = this.height;
					imgcopy.css({
						width: width+50,
						height: height+50,
					});
					$("#tempImgArea").find("#profile_img_seq").css({
						width: width,
						height: height,
					});
					$("#tempImgArea").show();
					$("#tempImgArea")
					.dialog({
						width : width+50,
						height	: height+50,
						modal : true,
						position : "center"
					})
					.on("click", function(){
						$("#tempImgArea").dialog("close");
						$("#tempImgArea").html("");
					});
				};
				
				
			});					
		});	
	}catch(e){}*/
	
});
				

function formattedDate(data) {
	var d = new Date(data);
	return d.getFullYear() + "년" + (d.getMonth() + 1) + "월" + d.getDate() + "일";
}

function getContextPath(){
    var offset=location.href.indexOf(location.host)+location.host.length;
    var ctxPath=location.href.substring(offset,location.href.indexOf('/',offset+1));
    return ctxPath;
}

function doSelectedatSelectbox(target, str) {
	$("select[name="+target+"] option[value="+str+"]").attr("selected",true);
};

function openCenterWindow(p_width, p_height, url, name) {
	var centeredY,centeredX;
	var width = p_width;
	var height = p_height;
	if ($.browser.msie) {//hacked together for IE browsers
		centeredY = (window.screenTop - 120) + ((((document.documentElement.clientHeight + 120)/2) - (height/2)));
		centeredX = window.screenLeft + ((((document.body.offsetWidth + 20)/2) - (width/2)));
	}else{
		centeredY = window.screenY + (((window.outerHeight/2) - (height/2)));
		centeredX = window.screenX + (((window.outerWidth/2) - (width/2)));
	}
	
	if(name==undefined || name.length==0)
		return window.open(url,'Mail','width='+width+', height='+height+', toolbar=no, location=no, stauts=no, scrollbars=2, resizable=yes, menubar=no, left='+centeredX+', top='+centeredY+'');
	else
		return window.open(url, name,'width='+width+', height='+height+', toolbar=no, location=no, stauts=no, scrollbars=2, resizable=yes, menubar=no, left='+centeredX+', top='+centeredY+'');
};


function urldecode(str) {
   return decodeURIComponent((str+'').replace(/\+/g, '%20'));
}

function urlEncode(str) {
	return encodeURIComponent(str);
}

function buildQueryString(parameters) {
	var qs = "";
	for ( var key in parameters) {
		var value = parameters[key];
		qs += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&";
	}
	if (qs.length > 0) {
		qs = qs.substring(0, qs.length - 1); //chop off last "&"
	}
	return "?"+qs;
}
